package com.trainingcloud.action.role;

import java.util.Vector;

import org.dom4j.Element;

import com.trainingcloud.XMLSerializer;
import com.trainingcloud.action.BaseSessionAction;
import com.trainingcloud.dao.RoleDAO;
import com.trainingcloud.entity.Role;
import com.trainingcloud.exception.DAOException;
import com.trainingcloud.exception.SystemException;

public class ListRoleAction extends BaseSessionAction 
{

	public ListRoleAction() throws SystemException 
	{
		super();
	}

	@Override
	public String callWithSession() throws DAOException, SystemException 
	{
		RoleDAO roleDAO = new RoleDAO();
		Vector<Role> roleList = roleDAO.getAllRoles();
		Element listElement = responseElement.addElement("roleList");
		for(int i=1; i<=roleList.size(); i++)
		{
			XMLSerializer.roleToXML(roleList.get(i-1), listElement);
		}
		
		return null;
	}

}
